package ui;

import javax.swing.*;
import java.awt.*;

public class LayerPoint extends Layer {

    //标题图片分数
    private   static final  Image IMG_POINT = new ImageIcon("graphics/string/point.png").getImage();
    //标题图片消行
    private   static final  Image IMG_RMLINE = new ImageIcon("graphics/string/rmline.png").getImage();
    //矩形值槽
    private   static final  Image IMG_RECT = new ImageIcon("graphics/window/rect.png").getImage();


    //消行y坐标
    private  final  int rmLineY;// = IMG_RMLINE.getHeight(null) + (PADDING << 1);
    //分数y坐标
    private  final int pointY;// = PADDING;
    //经验值y坐标
    private final int expY;
    //经验值宽度
    private final int expW;
    //分数最大位数
    private static final int POINGT_BIT = 5;
    //消行x坐标
    private   final int comX;
    //获得图片高度（矩形值槽高度）
    private  static  final int RECT_H = IMG_RECT.getHeight(null);

    public LayerPoint(int x, int y, int w, int h) {
        super(x,y,w,h);
        //初始化分数显示的x坐标
        this.comX = this.w - IMG_NUMBER_W * POINGT_BIT - PADDING;
        //初始化分数显示的y坐标
        this.pointY = PADDING;
        //初始化消行y坐标
        this.rmLineY = this.pointY + IMG_POINT.getHeight(null)+ PADDING;
        //初始化经验值y坐标
        this.expY = this.rmLineY + IMG_RMLINE.getHeight(null) + PADDING;
        //初始化经验值槽宽度
        this.expW = this.w - (PADDING << 1);
    }
    public void paint(Graphics g){
        this.createWindow(g);
        //窗口标题分数
        g.drawImage(IMG_POINT,this.x + PADDING,this.y+pointY,null);
        //显示分数
        this.drawNumberLefetPad(comX,pointY,this.dto.getNowPoint(),POINGT_BIT,g);
        //标题消行
        g.drawImage(IMG_RMLINE,this.x + PADDING,this.y+rmLineY,null);
        //显示消行数
        this.drawNumberLefetPad(comX,rmLineY,this.dto.getNowRempveline(),POINGT_BIT,g);
        //绘制经验值槽
//        this.drawRect(g);

    }
    private void drawRect(String title, String number, double value,double maxValue,Graphics g) {
        //各种值初始化
        int rect_x = this.x + PADDING;
        int rect_y = this.y + expY;
        //绘制背景
        g.setColor(Color.BLACK);
        g.fillRect(this.x + PADDING, this.y + expY,expW,RECT_H + 4);
        g.setColor(Color.WHITE);
        g.fillRect(this.x + PADDING + 1, this.y + expY + 1,expW - 2,RECT_H + 2);
        g.setColor(Color.BLACK);
        g.fillRect(this.x + PADDING + 2, this.y + expY + 2,expW - 4,RECT_H);
        //绘制值槽
        //求出比值
        double b = value / maxValue;
        //求出颜色
//        int subIdx = (int)(p * IMG_RECT_W);

        int w = (int)(value/maxValue * (this.expW - 4));
//        g.drawImage(IMG_RECT,
//                    this.x + PADDING + 2,this.y + expY + 2,
//                this.x + PADDING + 2 + 32 - 4,this.expW - 4,
//                );
    }
}
